﻿unit SplitString;


interface

uses
  SysUtils,
  Classes,
  Points;
//以逗号分隔字符串，保存为TPoint
function SplitStr(Str,SplitBy:String):TPoint;

//2.返回指针的 分隔字符串方法
function SplitStrP(Str,SplitBy:String):PPoint;


implementation

function SplitStr(Str,SplitBy:String):TPoint;
var
  Index : Integer;
  Point:TPoint;
begin
  Index := POS(SplitBy,Str);
  Point.X := StrToFloat(Copy(str,0,Index-1));
  Point.Y := StrToFloat(Copy(str,Index+1,Length(Str)-Index));
  Result := Point;
end;

function SplitStrP(Str,SplitBy:String):PPoint;
var
  Index : Integer;
  Point:PPoint;
begin
  new(Point);
  Index := POS(SplitBy,Str);
  Point.X := StrToFloat(Copy(str,0,Index-1));
  Point.Y := StrToFloat(Copy(str,Index+1,Length(Str)-Index));
  Result := Point;
end;

end.
